home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / haziran / 19 / setup.exe / data.z / isapnp_diag_lib.c < prev    next >
C/C++ Source or Header  |  2001-04-11  |  2KB  |  82 lines

  1. ////////////////////////////////////////////////////////////////
  2. // File - ISAPNP_DIAG_LIB.C
  3. //
  4. // Utility functions for printing card information,
  5. // detecting PCI cards, and accessing PCI configuration
  6. // registers.
  7. // 
  8. ////////////////////////////////////////////////////////////////
  9.  
  10. #include "../../include/windrvr.h"
  11. #ifdef _USE_SPECIFIC_KERNEL_DRIVER_
  12.     #undef WD_Open
  13.     #define WD_Open WD_OpenKernelHandle
  14.     #if defined(UNIX)
  15.         #undef WD_FUNCTION
  16.         #define WD_FUNCTION(wFuncNum,h,pParam,dwSize,fWait) ((ULONG) ioctl((int)(h), wFuncNum, pParam))
  17.     #endif
  18. #endif
  19. #include "print_struct.h"
  20. #include <stdio.h>
  21. #include "isapnp_diag_lib.h"
  22.  
  23. BOOL ISAPNP_Get_WD_handle(HANDLE *phWD)
  24. {
  25.     WD_VERSION ver;
  26.  
  27.     *phWD = INVALID_HANDLE_VALUE;
  28.     *phWD = WD_Open();
  29.  
  30.     // Check whether handle is valid and version OK
  31.     if (*phWD==INVALID_HANDLE_VALUE) 
  32.     {
  33.         printf("Failed opening " WD_PROD_NAME " device\n");
  34.         return FALSE;
  35.     }
  36.  
  37.     BZERO(ver);
  38.     WD_Version(*phWD,&ver);
  39.     if (ver.dwVer<WD_VER) 
  40.     {
  41.         printf("Incorrect " WD_PROD_NAME " version\n");
  42.         WD_Close (*phWD);
  43.         *phWD = INVALID_HANDLE_VALUE;
  44.         return FALSE;
  45.     }
  46.  
  47.     return TRUE;
  48. }
  49.  
  50. void ISAPNP_Print_all_cards_info()
  51. {
  52.     HANDLE hWD;
  53.     WD_ISAPNP_SCAN_CARDS scanCards;
  54.     WD_ISAPNP_CARD_INFO cardInfo;
  55.     DWORD i, j;
  56.  
  57.     if (!ISAPNP_Get_WD_handle (&hWD)) return;
  58.  
  59.     printf ("ISA PnP bus scan:\n\n");
  60.     BZERO(scanCards);
  61.     WD_IsapnpScanCards (hWD, &scanCards);
  62.     for (i=0; i<scanCards.dwCards; i++)
  63.     {
  64.         printf ("Card %d: %s\n", i, scanCards.Card[i].cIdent);
  65.         for (j=0; j<scanCards.Card[i].dwLogicalDevices; j++)
  66.         {
  67.             BZERO(cardInfo);
  68.             cardInfo.cardId = scanCards.Card[i].cardId;
  69.             cardInfo.dwLogicalDevice = j;
  70.             WD_IsapnpGetCardInfo(hWD, &cardInfo);
  71.             if (strlen(cardInfo.cIdent))
  72.                 printf ("Device %d: %s, ", j, cardInfo.cIdent);
  73.             printf ("Vendor ID: %s, ", scanCards.Card[i].cardId.cVendor );
  74.             printf ("Serial number: %x\n", scanCards.Card[i].cardId.dwSerial );
  75.             WD_CARD_print(&cardInfo.Card, "   ");
  76.             printf ("\n");
  77.         }
  78.     }
  79.     WD_Close (hWD);
  80. }
  81.  
  82.